package cn.lingyangwl.agile.common.security.constants;

import cn.lingyangwl.framework.tool.core.StringUtils;

/**
 * Query 数据规则 常量
 */
public enum DataRuleEnum {

    GT(">","gt","大于"),
    GE(">=","ge","大于等于"),
    LT("<","lt","小于"),
    LE("<=","le","小于等于"),
    EQ("=","eq","等于"),
    NE("!=","ne","不等于"),
    IN("IN","in","包含"),
    LIKE("LIKE","like","全模糊"),
    LEFT_LIKE("LEFT_LIKE","left_like","左模糊"),
    RIGHT_LIKE("RIGHT_LIKE","right_like","右模糊"),

    DATA_MY("DATA_MY","data_my","只看自己数据"),
    DATA_MY_CURRENT_DEPT("DATA_MY_CURRENT_DEPT","data_my_current_dept","当前部门数据及子部门数据"),
    DATA_MY_ALL_DEPT("DATA_MY_ALL_DEPT","data_my_all_dept","所属部门全部数据"),

    /** 目前没有支持的计划 */
    SQL_RULES("USE_SQL_RULES","ext","自定义SQL片段");

    private String value;
    
    private String condition; 

    private String msg;

    DataRuleEnum(String value, String condition, String msg){
        this.value = value;
        this.condition = condition;
        this.msg = msg;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public static DataRuleEnum getByValue(String value){
    	if(StringUtils.isEmpty(value)) {
    		return null;
    	}
        for(DataRuleEnum val :values()){
            if (val.getValue().equals(value) || val.getCondition().equals(value)){
                return val;
            }
        }
        return  null;
    }
}
